<template>

<div class="user-header">

  <el-form :inline="true" :model="formInline" class="demo-form-inline">
    <el-form-item label="用户名">
      <el-input v-model="formInline.user" placeholder="请输入用户名" clearable />
    </el-form-item>
    <el-form-item label="角色">
      <el-select style="width: 200px;"
        v-model="formInline.region"
        placeholder="请选择角色"
        clearable
      >
        <el-option label="学生" value="1" />
        <el-option label="老师" value="2" />
        <el-option label="管理员" value="3" />
      </el-select>
    </el-form-item>
    
    <el-form-item label="创建时间">
      <el-date-picker
        v-model="formInline.date"
        type="date"
        placeholder="请选择日期"
        clearable
      />
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="">搜索</el-button>
      <el-button type="primary" @click="">添加</el-button>
    </el-form-item>
  </el-form>

</div>

<div class="user-table">
  <el-table :data="tableData" style="width: 100%">
    <el-table-column fixed type="index" prop="date" label="序号" width="150" />
    <el-table-column prop="name" label="姓名" width="120" />
    <el-table-column prop="username" label="用户名" width="120" />
    <el-table-column prop="role.identity" label="角色" width="120" />
    <el-table-column prop="email" label="邮箱" width="200" />
    <el-table-column prop="isDeleted" label="是否可用" width="120">

      <!-- 卡槽 -->
      <template #default="item">
        <el-tag v-if="item.row.isDeleted === 1" type="success">可用</el-tag>
        <el-tag v-else type="danger">不可用</el-tag>
      </template>

    </el-table-column>


    <el-table-column fixed="right" label="操作" width="120">
      <template #default>
        <el-button link type="primary" size="small" @click="handleClick"
          >编辑</el-button
        >
        <el-button link type="danger" size="small">删除</el-button>
      </template>
    </el-table-column>
  </el-table>

  
</div>

<div class="user-pagination">

  <el-pagination
    small
    background
    layout="prev, pager, next"
    :total="500"
    class="mt-4"
  />

</div>


</template>

<script setup lang="ts">

import { reactive } from 'vue'

const formInline = reactive({
  user: '',
  region: '',
  date: '',
})

const onSubmit = () => {
  console.log('submit!')
}

const handleClick = () => {
  console.log('click')
}

const tableData = [
  {
    date: '2016-05-03',
    name: 'Tom',
    state: 'California',
    city: 'Los Angeles',
    address: 'No. 189, Grove St, Los Angeles',
    zip: 'CA 90036',
    isDeleted: 1,
  },
  {
    date: '2016-05-02',
    name: 'Tom',
    state: 'California',
    city: 'Los Angeles',
    address: 'No. 189, Grove St, Los Angeles',
    zip: 'CA 90036',
    isDeleted: 1,
  },
  {
    date: '2016-05-04',
    name: 'Tom',
    state: 'California',
    city: 'Los Angeles',
    address: 'No. 189, Grove St, Los Angeles',
    zip: 'CA 90036',
    isDeleted: 1,
  },
  {
    date: '2016-05-01',
    name: 'Tom',
    state: 'California',
    city: 'Los Angeles',
    address: 'No. 189, Grove St, Los Angeles',
    zip: 'CA 90036',
    isDeleted: 0,
  },
]

</script>

<style scoped>
.user-header{
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;


}

.user-table{
    margin-bottom: 20px;
}


.demo-form-inline .el-input {
  --el-input-width: 220px;
}
</style>